package com.example.bookkeepingelf.business.database.entity;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import androidx.room.TypeConverters;

import com.alibaba.fastjson.annotation.JSONField;
import com.example.bookkeepingelf.business.database.converter.BigDecimalConverter;
import com.example.bookkeepingelf.business.database.converter.BooleanConverter;
import com.example.bookkeepingelf.business.database.converter.DateConverter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@Entity(tableName = "account_book")
public class AccountBook {

    public AccountBook() {
    }


    public AccountBook(Integer id, String accountBookName, String icon, BigDecimal amount, Date createTime, Date updateTime, Boolean isMain) {
        this.id = id;
        this.accountBookName = accountBookName;
        this.icon = icon;
        this.amount = amount;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.isMain = isMain;
    }

    @PrimaryKey(autoGenerate = true)
    private Integer id;

    /**
     * 账本名称
     */
    @ColumnInfo(name = "account_book_name")
    private String accountBookName;

    /**
     * 账本图标
     */
    @ColumnInfo(name = "icon")
    private String icon;

    /**
     * 账本余额
     */
    @ColumnInfo(name = "amount")
    @TypeConverters(BigDecimalConverter.class)
    private BigDecimal amount;

    /**
     * 创建时间
     */
    @ColumnInfo(name = "create_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TypeConverters(DateConverter.class)
    private Date createTime;

    /**
     * 更新时间
     */
    @ColumnInfo(name = "update_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TypeConverters(DateConverter.class)
    private Date updateTime;

    /**
     * 是否为主账本
     */
    @ColumnInfo(name = "is_main")
    @TypeConverters(BooleanConverter.class)
    private Boolean isMain;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAccountBookName() {
        return accountBookName;
    }

    public void setAccountBookName(String accountBookName) {
        this.accountBookName = accountBookName;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Boolean getMain() {
        return isMain;
    }

    public void setMain(Boolean main) {
        isMain = main;
    }
}
